<?php
class Widget_GoogleCalendar_TwigExtension extends Twig_Extension
{
  public function getFilters()
  {
    return array(
      'autolink' => array('w_gc_te_autolink', false),
      'textile'  => array('w_gc_te_textile', false),
      );
  }
  
  public function getName()
  {
    return 'Widget_GoogleCalendar';
  }
}

function w_gc_te_autolink($text)
{
  return preg_replace("~([a-zA-Z]+://([.]?[a-zA-Z0-9_/-])*)~", '<a href="\\0">\\0</a>', $text);
}

function w_gc_te_textile($text)
{
  $textile = new Textile();
  return $textile->TextileThis($text);
}
